#include "live.h"

namespace {
#define DIM 22
#define EDIM 21
#define MEDIM 21
typedef void (*Hfun)(double *, double *, double *);
const static double MAHA_THRESH_4 = 7.814727903251177;
const static double MAHA_THRESH_9 = 7.814727903251177;
const static double MAHA_THRESH_10 = 7.814727903251177;
const static double MAHA_THRESH_12 = 7.814727903251177;
const static double MAHA_THRESH_35 = 7.814727903251177;
const static double MAHA_THRESH_32 = 9.487729036781154;
const static double MAHA_THRESH_13 = 7.814727903251177;
const static double MAHA_THRESH_14 = 7.814727903251177;
const static double MAHA_THRESH_33 = 7.814727903251177;

/******************************************************************************
 *                       Code generated with SymPy 1.12                       *
 *                                                                            *
 *              See http://www.sympy.org/ for more information.               *
 *                                                                            *
 *                         This file is part of 'ekf'                         *
 ******************************************************************************/
void H(double *in_vec, double *out_3062539955778785123) {
   out_3062539955778785123[0] = 0;
   out_3062539955778785123[1] = -sin(in_vec[1])*sin(in_vec[2])*in_vec[4] - sin(in_vec[1])*cos(in_vec[2])*in_vec[3] - cos(in_vec[1])*in_vec[5];
   out_3062539955778785123[2] = -sin(in_vec[2])*cos(in_vec[1])*in_vec[3] + cos(in_vec[1])*cos(in_vec[2])*in_vec[4];
   out_3062539955778785123[3] = cos(in_vec[1])*cos(in_vec[2]);
   out_3062539955778785123[4] = sin(in_vec[2])*cos(in_vec[1]);
   out_3062539955778785123[5] = -sin(in_vec[1]);
   out_3062539955778785123[6] = (sin(in_vec[0])*sin(in_vec[2]) + sin(in_vec[1])*cos(in_vec[0])*cos(in_vec[2]))*in_vec[3] + (-sin(in_vec[0])*cos(in_vec[2]) + sin(in_vec[1])*sin(in_vec[2])*cos(in_vec[0]))*in_vec[4] + cos(in_vec[0])*cos(in_vec[1])*in_vec[5];
   out_3062539955778785123[7] = -sin(in_vec[0])*sin(in_vec[1])*in_vec[5] + sin(in_vec[0])*sin(in_vec[2])*cos(in_vec[1])*in_vec[4] + sin(in_vec[0])*cos(in_vec[1])*cos(in_vec[2])*in_vec[3];
   out_3062539955778785123[8] = (-sin(in_vec[0])*sin(in_vec[1])*sin(in_vec[2]) - cos(in_vec[0])*cos(in_vec[2]))*in_vec[3] + (sin(in_vec[0])*sin(in_vec[1])*cos(in_vec[2]) - sin(in_vec[2])*cos(in_vec[0]))*in_vec[4];
   out_3062539955778785123[9] = sin(in_vec[0])*sin(in_vec[1])*cos(in_vec[2]) - sin(in_vec[2])*cos(in_vec[0]);
   out_3062539955778785123[10] = sin(in_vec[0])*sin(in_vec[1])*sin(in_vec[2]) + cos(in_vec[0])*cos(in_vec[2]);
   out_3062539955778785123[11] = sin(in_vec[0])*cos(in_vec[1]);
   out_3062539955778785123[12] = (-sin(in_vec[0])*sin(in_vec[1])*sin(in_vec[2]) - cos(in_vec[0])*cos(in_vec[2]))*in_vec[4] + (-sin(in_vec[0])*sin(in_vec[1])*cos(in_vec[2]) + sin(in_vec[2])*cos(in_vec[0]))*in_vec[3] - sin(in_vec[0])*cos(in_vec[1])*in_vec[5];
   out_3062539955778785123[13] = -sin(in_vec[1])*cos(in_vec[0])*in_vec[5] + sin(in_vec[2])*cos(in_vec[0])*cos(in_vec[1])*in_vec[4] + cos(in_vec[0])*cos(in_vec[1])*cos(in_vec[2])*in_vec[3];
   out_3062539955778785123[14] = (sin(in_vec[0])*sin(in_vec[2]) + sin(in_vec[1])*cos(in_vec[0])*cos(in_vec[2]))*in_vec[4] + (sin(in_vec[0])*cos(in_vec[2]) - sin(in_vec[1])*sin(in_vec[2])*cos(in_vec[0]))*in_vec[3];
   out_3062539955778785123[15] = sin(in_vec[0])*sin(in_vec[2]) + sin(in_vec[1])*cos(in_vec[0])*cos(in_vec[2]);
   out_3062539955778785123[16] = -sin(in_vec[0])*cos(in_vec[2]) + sin(in_vec[1])*sin(in_vec[2])*cos(in_vec[0]);
   out_3062539955778785123[17] = cos(in_vec[0])*cos(in_vec[1]);
}
void err_fun(double *nom_x, double *delta_x, double *out_997632986539046101) {
   out_997632986539046101[0] = delta_x[0] + nom_x[0];
   out_997632986539046101[1] = delta_x[1] + nom_x[1];
   out_997632986539046101[2] = delta_x[2] + nom_x[2];
   out_997632986539046101[3] = -0.5*delta_x[3]*nom_x[4] - 0.5*delta_x[4]*nom_x[5] - 0.5*delta_x[5]*nom_x[6] + 1.0*nom_x[3];
   out_997632986539046101[4] = 0.5*delta_x[3]*nom_x[3] + 0.5*delta_x[4]*nom_x[6] - 0.5*delta_x[5]*nom_x[5] + 1.0*nom_x[4];
   out_997632986539046101[5] = -0.5*delta_x[3]*nom_x[6] + 0.5*delta_x[4]*nom_x[3] + 0.5*delta_x[5]*nom_x[4] + 1.0*nom_x[5];
   out_997632986539046101[6] = 0.5*delta_x[3]*nom_x[5] - 0.5*delta_x[4]*nom_x[4] + 0.5*delta_x[5]*nom_x[3] + 1.0*nom_x[6];
   out_997632986539046101[7] = delta_x[6] + nom_x[7];
   out_997632986539046101[8] = delta_x[7] + nom_x[8];
   out_997632986539046101[9] = delta_x[8] + nom_x[9];
   out_997632986539046101[10] = delta_x[9] + nom_x[10];
   out_997632986539046101[11] = delta_x[10] + nom_x[11];
   out_997632986539046101[12] = delta_x[11] + nom_x[12];
   out_997632986539046101[13] = delta_x[12] + nom_x[13];
   out_997632986539046101[14] = delta_x[13] + nom_x[14];
   out_997632986539046101[15] = delta_x[14] + nom_x[15];
   out_997632986539046101[16] = delta_x[15] + nom_x[16];
   out_997632986539046101[17] = delta_x[16] + nom_x[17];
   out_997632986539046101[18] = delta_x[17] + nom_x[18];
   out_997632986539046101[19] = delta_x[18] + nom_x[19];
   out_997632986539046101[20] = delta_x[19] + nom_x[20];
   out_997632986539046101[21] = delta_x[20] + nom_x[21];
}
void inv_err_fun(double *nom_x, double *true_x, double *out_3959944895181216754) {
   out_3959944895181216754[0] = -nom_x[0] + true_x[0];
   out_3959944895181216754[1] = -nom_x[1] + true_x[1];
   out_3959944895181216754[2] = -nom_x[2] + true_x[2];
   out_3959944895181216754[3] = 2*nom_x[3]*true_x[4] - 2*nom_x[4]*true_x[3] + 2*nom_x[5]*true_x[6] - 2*nom_x[6]*true_x[5];
   out_3959944895181216754[4] = 2*nom_x[3]*true_x[5] - 2*nom_x[4]*true_x[6] - 2*nom_x[5]*true_x[3] + 2*nom_x[6]*true_x[4];
   out_3959944895181216754[5] = 2*nom_x[3]*true_x[6] + 2*nom_x[4]*true_x[5] - 2*nom_x[5]*true_x[4] - 2*nom_x[6]*true_x[3];
   out_3959944895181216754[6] = -nom_x[7] + true_x[7];
   out_3959944895181216754[7] = -nom_x[8] + true_x[8];
   out_3959944895181216754[8] = -nom_x[9] + true_x[9];
   out_3959944895181216754[9] = -nom_x[10] + true_x[10];
   out_3959944895181216754[10] = -nom_x[11] + true_x[11];
   out_3959944895181216754[11] = -nom_x[12] + true_x[12];
   out_3959944895181216754[12] = -nom_x[13] + true_x[13];
   out_3959944895181216754[13] = -nom_x[14] + true_x[14];
   out_3959944895181216754[14] = -nom_x[15] + true_x[15];
   out_3959944895181216754[15] = -nom_x[16] + true_x[16];
   out_3959944895181216754[16] = -nom_x[17] + true_x[17];
   out_3959944895181216754[17] = -nom_x[18] + true_x[18];
   out_3959944895181216754[18] = -nom_x[19] + true_x[19];
   out_3959944895181216754[19] = -nom_x[20] + true_x[20];
   out_3959944895181216754[20] = -nom_x[21] + true_x[21];
}
void H_mod_fun(double *state, double *out_8702234888023658226) {
   out_8702234888023658226[0] = 1.0;
   out_8702234888023658226[1] = 0;
   out_8702234888023658226[2] = 0;
   out_8702234888023658226[3] = 0;
   out_8702234888023658226[4] = 0;
   out_8702234888023658226[5] = 0;
   out_8702234888023658226[6] = 0;
   out_8702234888023658226[7] = 0;
   out_8702234888023658226[8] = 0;
   out_8702234888023658226[9] = 0;
   out_8702234888023658226[10] = 0;
   out_8702234888023658226[11] = 0;
   out_8702234888023658226[12] = 0;
   out_8702234888023658226[13] = 0;
   out_8702234888023658226[14] = 0;
   out_8702234888023658226[15] = 0;
   out_8702234888023658226[16] = 0;
   out_8702234888023658226[17] = 0;
   out_8702234888023658226[18] = 0;
   out_8702234888023658226[19] = 0;
   out_8702234888023658226[20] = 0;
   out_8702234888023658226[21] = 0;
   out_8702234888023658226[22] = 1.0;
   out_8702234888023658226[23] = 0;
   out_8702234888023658226[24] = 0;
   out_8702234888023658226[25] = 0;
   out_8702234888023658226[26] = 0;
   out_8702234888023658226[27] = 0;
   out_8702234888023658226[28] = 0;
   out_8702234888023658226[29] = 0;
   out_8702234888023658226[30] = 0;
   out_8702234888023658226[31] = 0;
   out_8702234888023658226[32] = 0;
   out_8702234888023658226[33] = 0;
   out_8702234888023658226[34] = 0;
   out_8702234888023658226[35] = 0;
   out_8702234888023658226[36] = 0;
   out_8702234888023658226[37] = 0;
   out_8702234888023658226[38] = 0;
   out_8702234888023658226[39] = 0;
   out_8702234888023658226[40] = 0;
   out_8702234888023658226[41] = 0;
   out_8702234888023658226[42] = 0;
   out_8702234888023658226[43] = 0;
   out_8702234888023658226[44] = 1.0;
   out_8702234888023658226[45] = 0;
   out_8702234888023658226[46] = 0;
   out_8702234888023658226[47] = 0;
   out_8702234888023658226[48] = 0;
   out_8702234888023658226[49] = 0;
   out_8702234888023658226[50] = 0;
   out_8702234888023658226[51] = 0;
   out_8702234888023658226[52] = 0;
   out_8702234888023658226[53] = 0;
   out_8702234888023658226[54] = 0;
   out_8702234888023658226[55] = 0;
   out_8702234888023658226[56] = 0;
   out_8702234888023658226[57] = 0;
   out_8702234888023658226[58] = 0;
   out_8702234888023658226[59] = 0;
   out_8702234888023658226[60] = 0;
   out_8702234888023658226[61] = 0;
   out_8702234888023658226[62] = 0;
   out_8702234888023658226[63] = 0;
   out_8702234888023658226[64] = 0;
   out_8702234888023658226[65] = 0;
   out_8702234888023658226[66] = -0.5*state[4];
   out_8702234888023658226[67] = -0.5*state[5];
   out_8702234888023658226[68] = -0.5*state[6];
   out_8702234888023658226[69] = 0;
   out_8702234888023658226[70] = 0;
   out_8702234888023658226[71] = 0;
   out_8702234888023658226[72] = 0;
   out_8702234888023658226[73] = 0;
   out_8702234888023658226[74] = 0;
   out_8702234888023658226[75] = 0;
   out_8702234888023658226[76] = 0;
   out_8702234888023658226[77] = 0;
   out_8702234888023658226[78] = 0;
   out_8702234888023658226[79] = 0;
   out_8702234888023658226[80] = 0;
   out_8702234888023658226[81] = 0;
   out_8702234888023658226[82] = 0;
   out_8702234888023658226[83] = 0;
   out_8702234888023658226[84] = 0;
   out_8702234888023658226[85] = 0;
   out_8702234888023658226[86] = 0;
   out_8702234888023658226[87] = 0.5*state[3];
   out_8702234888023658226[88] = 0.5*state[6];
   out_8702234888023658226[89] = -0.5*state[5];
   out_8702234888023658226[90] = 0;
   out_8702234888023658226[91] = 0;
   out_8702234888023658226[92] = 0;
   out_8702234888023658226[93] = 0;
   out_8702234888023658226[94] = 0;
   out_8702234888023658226[95] = 0;
   out_8702234888023658226[96] = 0;
   out_8702234888023658226[97] = 0;
   out_8702234888023658226[98] = 0;
   out_8702234888023658226[99] = 0;
   out_8702234888023658226[100] = 0;
   out_8702234888023658226[101] = 0;
   out_8702234888023658226[102] = 0;
   out_8702234888023658226[103] = 0;
   out_8702234888023658226[104] = 0;
   out_8702234888023658226[105] = 0;
   out_8702234888023658226[106] = 0;
   out_8702234888023658226[107] = 0;
   out_8702234888023658226[108] = -0.5*state[6];
   out_8702234888023658226[109] = 0.5*state[3];
   out_8702234888023658226[110] = 0.5*state[4];
   out_8702234888023658226[111] = 0;
   out_8702234888023658226[112] = 0;
   out_8702234888023658226[113] = 0;
   out_8702234888023658226[114] = 0;
   out_8702234888023658226[115] = 0;
   out_8702234888023658226[116] = 0;
   out_8702234888023658226[117] = 0;
   out_8702234888023658226[118] = 0;
   out_8702234888023658226[119] = 0;
   out_8702234888023658226[120] = 0;
   out_8702234888023658226[121] = 0;
   out_8702234888023658226[122] = 0;
   out_8702234888023658226[123] = 0;
   out_8702234888023658226[124] = 0;
   out_8702234888023658226[125] = 0;
   out_8702234888023658226[126] = 0;
   out_8702234888023658226[127] = 0;
   out_8702234888023658226[128] = 0;
   out_8702234888023658226[129] = 0.5*state[5];
   out_8702234888023658226[130] = -0.5*state[4];
   out_8702234888023658226[131] = 0.5*state[3];
   out_8702234888023658226[132] = 0;
   out_8702234888023658226[133] = 0;
   out_8702234888023658226[134] = 0;
   out_8702234888023658226[135] = 0;
   out_8702234888023658226[136] = 0;
   out_8702234888023658226[137] = 0;
   out_8702234888023658226[138] = 0;
   out_8702234888023658226[139] = 0;
   out_8702234888023658226[140] = 0;
   out_8702234888023658226[141] = 0;
   out_8702234888023658226[142] = 0;
   out_8702234888023658226[143] = 0;
   out_8702234888023658226[144] = 0;
   out_8702234888023658226[145] = 0;
   out_8702234888023658226[146] = 0;
   out_8702234888023658226[147] = 0;
   out_8702234888023658226[148] = 0;
   out_8702234888023658226[149] = 0;
   out_8702234888023658226[150] = 0;
   out_8702234888023658226[151] = 0;
   out_8702234888023658226[152] = 0;
   out_8702234888023658226[153] = 1.0;
   out_8702234888023658226[154] = 0;
   out_8702234888023658226[155] = 0;
   out_8702234888023658226[156] = 0;
   out_8702234888023658226[157] = 0;
   out_8702234888023658226[158] = 0;
   out_8702234888023658226[159] = 0;
   out_8702234888023658226[160] = 0;
   out_8702234888023658226[161] = 0;
   out_8702234888023658226[162] = 0;
   out_8702234888023658226[163] = 0;
   out_8702234888023658226[164] = 0;
   out_8702234888023658226[165] = 0;
   out_8702234888023658226[166] = 0;
   out_8702234888023658226[167] = 0;
   out_8702234888023658226[168] = 0;
   out_8702234888023658226[169] = 0;
   out_8702234888023658226[170] = 0;
   out_8702234888023658226[171] = 0;
   out_8702234888023658226[172] = 0;
   out_8702234888023658226[173] = 0;
   out_8702234888023658226[174] = 0;
   out_8702234888023658226[175] = 1.0;
   out_8702234888023658226[176] = 0;
   out_8702234888023658226[177] = 0;
   out_8702234888023658226[178] = 0;
   out_8702234888023658226[179] = 0;
   out_8702234888023658226[180] = 0;
   out_8702234888023658226[181] = 0;
   out_8702234888023658226[182] = 0;
   out_8702234888023658226[183] = 0;
   out_8702234888023658226[184] = 0;
   out_8702234888023658226[185] = 0;
   out_8702234888023658226[186] = 0;
   out_8702234888023658226[187] = 0;
   out_8702234888023658226[188] = 0;
   out_8702234888023658226[189] = 0;
   out_8702234888023658226[190] = 0;
   out_8702234888023658226[191] = 0;
   out_8702234888023658226[192] = 0;
   out_8702234888023658226[193] = 0;
   out_8702234888023658226[194] = 0;
   out_8702234888023658226[195] = 0;
   out_8702234888023658226[196] = 0;
   out_8702234888023658226[197] = 1.0;
   out_8702234888023658226[198] = 0;
   out_8702234888023658226[199] = 0;
   out_8702234888023658226[200] = 0;
   out_8702234888023658226[201] = 0;
   out_8702234888023658226[202] = 0;
   out_8702234888023658226[203] = 0;
   out_8702234888023658226[204] = 0;
   out_8702234888023658226[205] = 0;
   out_8702234888023658226[206] = 0;
   out_8702234888023658226[207] = 0;
   out_8702234888023658226[208] = 0;
   out_8702234888023658226[209] = 0;
   out_8702234888023658226[210] = 0;
   out_8702234888023658226[211] = 0;
   out_8702234888023658226[212] = 0;
   out_8702234888023658226[213] = 0;
   out_8702234888023658226[214] = 0;
   out_8702234888023658226[215] = 0;
   out_8702234888023658226[216] = 0;
   out_8702234888023658226[217] = 0;
   out_8702234888023658226[218] = 0;
   out_8702234888023658226[219] = 1.0;
   out_8702234888023658226[220] = 0;
   out_8702234888023658226[221] = 0;
   out_8702234888023658226[222] = 0;
   out_8702234888023658226[223] = 0;
   out_8702234888023658226[224] = 0;
   out_8702234888023658226[225] = 0;
   out_8702234888023658226[226] = 0;
   out_8702234888023658226[227] = 0;
   out_8702234888023658226[228] = 0;
   out_8702234888023658226[229] = 0;
   out_8702234888023658226[230] = 0;
   out_8702234888023658226[231] = 0;
   out_8702234888023658226[232] = 0;
   out_8702234888023658226[233] = 0;
   out_8702234888023658226[234] = 0;
   out_8702234888023658226[235] = 0;
   out_8702234888023658226[236] = 0;
   out_8702234888023658226[237] = 0;
   out_8702234888023658226[238] = 0;
   out_8702234888023658226[239] = 0;
   out_8702234888023658226[240] = 0;
   out_8702234888023658226[241] = 1.0;
   out_8702234888023658226[242] = 0;
   out_8702234888023658226[243] = 0;
   out_8702234888023658226[244] = 0;
   out_8702234888023658226[245] = 0;
   out_8702234888023658226[246] = 0;
   out_8702234888023658226[247] = 0;
   out_8702234888023658226[248] = 0;
   out_8702234888023658226[249] = 0;
   out_8702234888023658226[250] = 0;
   out_8702234888023658226[251] = 0;
   out_8702234888023658226[252] = 0;
   out_8702234888023658226[253] = 0;
   out_8702234888023658226[254] = 0;
   out_8702234888023658226[255] = 0;
   out_8702234888023658226[256] = 0;
   out_8702234888023658226[257] = 0;
   out_8702234888023658226[258] = 0;
   out_8702234888023658226[259] = 0;
   out_8702234888023658226[260] = 0;
   out_8702234888023658226[261] = 0;
   out_8702234888023658226[262] = 0;
   out_8702234888023658226[263] = 1.0;
   out_8702234888023658226[264] = 0;
   out_8702234888023658226[265] = 0;
   out_8702234888023658226[266] = 0;
   out_8702234888023658226[267] = 0;
   out_8702234888023658226[268] = 0;
   out_8702234888023658226[269] = 0;
   out_8702234888023658226[270] = 0;
   out_8702234888023658226[271] = 0;
   out_8702234888023658226[272] = 0;
   out_8702234888023658226[273] = 0;
   out_8702234888023658226[274] = 0;
   out_8702234888023658226[275] = 0;
   out_8702234888023658226[276] = 0;
   out_8702234888023658226[277] = 0;
   out_8702234888023658226[278] = 0;
   out_8702234888023658226[279] = 0;
   out_8702234888023658226[280] = 0;
   out_8702234888023658226[281] = 0;
   out_8702234888023658226[282] = 0;
   out_8702234888023658226[283] = 0;
   out_8702234888023658226[284] = 0;
   out_8702234888023658226[285] = 1.0;
   out_8702234888023658226[286] = 0;
   out_8702234888023658226[287] = 0;
   out_8702234888023658226[288] = 0;
   out_8702234888023658226[289] = 0;
   out_8702234888023658226[290] = 0;
   out_8702234888023658226[291] = 0;
   out_8702234888023658226[292] = 0;
   out_8702234888023658226[293] = 0;
   out_8702234888023658226[294] = 0;
   out_8702234888023658226[295] = 0;
   out_8702234888023658226[296] = 0;
   out_8702234888023658226[297] = 0;
   out_8702234888023658226[298] = 0;
   out_8702234888023658226[299] = 0;
   out_8702234888023658226[300] = 0;
   out_8702234888023658226[301] = 0;
   out_8702234888023658226[302] = 0;
   out_8702234888023658226[303] = 0;
   out_8702234888023658226[304] = 0;
   out_8702234888023658226[305] = 0;
   out_8702234888023658226[306] = 0;
   out_8702234888023658226[307] = 1.0;
   out_8702234888023658226[308] = 0;
   out_8702234888023658226[309] = 0;
   out_8702234888023658226[310] = 0;
   out_8702234888023658226[311] = 0;
   out_8702234888023658226[312] = 0;
   out_8702234888023658226[313] = 0;
   out_8702234888023658226[314] = 0;
   out_8702234888023658226[315] = 0;
   out_8702234888023658226[316] = 0;
   out_8702234888023658226[317] = 0;
   out_8702234888023658226[318] = 0;
   out_8702234888023658226[319] = 0;
   out_8702234888023658226[320] = 0;
   out_8702234888023658226[321] = 0;
   out_8702234888023658226[322] = 0;
   out_8702234888023658226[323] = 0;
   out_8702234888023658226[324] = 0;
   out_8702234888023658226[325] = 0;
   out_8702234888023658226[326] = 0;
   out_8702234888023658226[327] = 0;
   out_8702234888023658226[328] = 0;
   out_8702234888023658226[329] = 1.0;
   out_8702234888023658226[330] = 0;
   out_8702234888023658226[331] = 0;
   out_8702234888023658226[332] = 0;
   out_8702234888023658226[333] = 0;
   out_8702234888023658226[334] = 0;
   out_8702234888023658226[335] = 0;
   out_8702234888023658226[336] = 0;
   out_8702234888023658226[337] = 0;
   out_8702234888023658226[338] = 0;
   out_8702234888023658226[339] = 0;
   out_8702234888023658226[340] = 0;
   out_8702234888023658226[341] = 0;
   out_8702234888023658226[342] = 0;
   out_8702234888023658226[343] = 0;
   out_8702234888023658226[344] = 0;
   out_8702234888023658226[345] = 0;
   out_8702234888023658226[346] = 0;
   out_8702234888023658226[347] = 0;
   out_8702234888023658226[348] = 0;
   out_8702234888023658226[349] = 0;
   out_8702234888023658226[350] = 0;
   out_8702234888023658226[351] = 1.0;
   out_8702234888023658226[352] = 0;
   out_8702234888023658226[353] = 0;
   out_8702234888023658226[354] = 0;
   out_8702234888023658226[355] = 0;
   out_8702234888023658226[356] = 0;
   out_8702234888023658226[357] = 0;
   out_8702234888023658226[358] = 0;
   out_8702234888023658226[359] = 0;
   out_8702234888023658226[360] = 0;
   out_8702234888023658226[361] = 0;
   out_8702234888023658226[362] = 0;
   out_8702234888023658226[363] = 0;
   out_8702234888023658226[364] = 0;
   out_8702234888023658226[365] = 0;
   out_8702234888023658226[366] = 0;
   out_8702234888023658226[367] = 0;
   out_8702234888023658226[368] = 0;
   out_8702234888023658226[369] = 0;
   out_8702234888023658226[370] = 0;
   out_8702234888023658226[371] = 0;
   out_8702234888023658226[372] = 0;
   out_8702234888023658226[373] = 1.0;
   out_8702234888023658226[374] = 0;
   out_8702234888023658226[375] = 0;
   out_8702234888023658226[376] = 0;
   out_8702234888023658226[377] = 0;
   out_8702234888023658226[378] = 0;
   out_8702234888023658226[379] = 0;
   out_8702234888023658226[380] = 0;
   out_8702234888023658226[381] = 0;
   out_8702234888023658226[382] = 0;
   out_8702234888023658226[383] = 0;
   out_8702234888023658226[384] = 0;
   out_8702234888023658226[385] = 0;
   out_8702234888023658226[386] = 0;
   out_8702234888023658226[387] = 0;
   out_8702234888023658226[388] = 0;
   out_8702234888023658226[389] = 0;
   out_8702234888023658226[390] = 0;
   out_8702234888023658226[391] = 0;
   out_8702234888023658226[392] = 0;
   out_8702234888023658226[393] = 0;
   out_8702234888023658226[394] = 0;
   out_8702234888023658226[395] = 1.0;
   out_8702234888023658226[396] = 0;
   out_8702234888023658226[397] = 0;
   out_8702234888023658226[398] = 0;
   out_8702234888023658226[399] = 0;
   out_8702234888023658226[400] = 0;
   out_8702234888023658226[401] = 0;
   out_8702234888023658226[402] = 0;
   out_8702234888023658226[403] = 0;
   out_8702234888023658226[404] = 0;
   out_8702234888023658226[405] = 0;
   out_8702234888023658226[406] = 0;
   out_8702234888023658226[407] = 0;
   out_8702234888023658226[408] = 0;
   out_8702234888023658226[409] = 0;
   out_8702234888023658226[410] = 0;
   out_8702234888023658226[411] = 0;
   out_8702234888023658226[412] = 0;
   out_8702234888023658226[413] = 0;
   out_8702234888023658226[414] = 0;
   out_8702234888023658226[415] = 0;
   out_8702234888023658226[416] = 0;
   out_8702234888023658226[417] = 1.0;
   out_8702234888023658226[418] = 0;
   out_8702234888023658226[419] = 0;
   out_8702234888023658226[420] = 0;
   out_8702234888023658226[421] = 0;
   out_8702234888023658226[422] = 0;
   out_8702234888023658226[423] = 0;
   out_8702234888023658226[424] = 0;
   out_8702234888023658226[425] = 0;
   out_8702234888023658226[426] = 0;
   out_8702234888023658226[427] = 0;
   out_8702234888023658226[428] = 0;
   out_8702234888023658226[429] = 0;
   out_8702234888023658226[430] = 0;
   out_8702234888023658226[431] = 0;
   out_8702234888023658226[432] = 0;
   out_8702234888023658226[433] = 0;
   out_8702234888023658226[434] = 0;
   out_8702234888023658226[435] = 0;
   out_8702234888023658226[436] = 0;
   out_8702234888023658226[437] = 0;
   out_8702234888023658226[438] = 0;
   out_8702234888023658226[439] = 1.0;
   out_8702234888023658226[440] = 0;
   out_8702234888023658226[441] = 0;
   out_8702234888023658226[442] = 0;
   out_8702234888023658226[443] = 0;
   out_8702234888023658226[444] = 0;
   out_8702234888023658226[445] = 0;
   out_8702234888023658226[446] = 0;
   out_8702234888023658226[447] = 0;
   out_8702234888023658226[448] = 0;
   out_8702234888023658226[449] = 0;
   out_8702234888023658226[450] = 0;
   out_8702234888023658226[451] = 0;
   out_8702234888023658226[452] = 0;
   out_8702234888023658226[453] = 0;
   out_8702234888023658226[454] = 0;
   out_8702234888023658226[455] = 0;
   out_8702234888023658226[456] = 0;
   out_8702234888023658226[457] = 0;
   out_8702234888023658226[458] = 0;
   out_8702234888023658226[459] = 0;
   out_8702234888023658226[460] = 0;
   out_8702234888023658226[461] = 1.0;
}
void f_fun(double *state, double dt, double *out_7459231211064544538) {
   out_7459231211064544538[0] = dt*state[7] + state[0];
   out_7459231211064544538[1] = dt*state[8] + state[1];
   out_7459231211064544538[2] = dt*state[9] + state[2];
   out_7459231211064544538[3] = dt*(-0.5*state[4]*state[10] - 0.5*state[5]*state[11] - 0.5*state[6]*state[12]) + state[3];
   out_7459231211064544538[4] = dt*(0.5*state[3]*state[10] + 0.5*state[5]*state[12] - 0.5*state[6]*state[11]) + state[4];
   out_7459231211064544538[5] = dt*(0.5*state[3]*state[11] - 0.5*state[4]*state[12] + 0.5*state[6]*state[10]) + state[5];
   out_7459231211064544538[6] = dt*(0.5*state[3]*state[12] + 0.5*state[4]*state[11] - 0.5*state[5]*state[10]) + state[6];
   out_7459231211064544538[7] = dt*((2*state[3]*state[5] + 2*state[4]*state[6])*state[18] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[17] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[16]) + state[7];
   out_7459231211064544538[8] = dt*((-2*state[3]*state[4] + 2*state[5]*state[6])*state[18] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[16] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[17]) + state[8];
   out_7459231211064544538[9] = dt*((2*state[3]*state[4] + 2*state[5]*state[6])*state[17] + (-2*state[3]*state[5] + 2*state[4]*state[6])*state[16] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[18]) + state[9];
   out_7459231211064544538[10] = state[10];
   out_7459231211064544538[11] = state[11];
   out_7459231211064544538[12] = state[12];
   out_7459231211064544538[13] = state[13];
   out_7459231211064544538[14] = state[14];
   out_7459231211064544538[15] = state[15];
   out_7459231211064544538[16] = state[16];
   out_7459231211064544538[17] = state[17];
   out_7459231211064544538[18] = state[18];
   out_7459231211064544538[19] = state[19];
   out_7459231211064544538[20] = state[20];
   out_7459231211064544538[21] = state[21];
}
void F_fun(double *state, double dt, double *out_8962950086978682024) {
   out_8962950086978682024[0] = 1;
   out_8962950086978682024[1] = 0;
   out_8962950086978682024[2] = 0;
   out_8962950086978682024[3] = 0;
   out_8962950086978682024[4] = 0;
   out_8962950086978682024[5] = 0;
   out_8962950086978682024[6] = dt;
   out_8962950086978682024[7] = 0;
   out_8962950086978682024[8] = 0;
   out_8962950086978682024[9] = 0;
   out_8962950086978682024[10] = 0;
   out_8962950086978682024[11] = 0;
   out_8962950086978682024[12] = 0;
   out_8962950086978682024[13] = 0;
   out_8962950086978682024[14] = 0;
   out_8962950086978682024[15] = 0;
   out_8962950086978682024[16] = 0;
   out_8962950086978682024[17] = 0;
   out_8962950086978682024[18] = 0;
   out_8962950086978682024[19] = 0;
   out_8962950086978682024[20] = 0;
   out_8962950086978682024[21] = 0;
   out_8962950086978682024[22] = 1;
   out_8962950086978682024[23] = 0;
   out_8962950086978682024[24] = 0;
   out_8962950086978682024[25] = 0;
   out_8962950086978682024[26] = 0;
   out_8962950086978682024[27] = 0;
   out_8962950086978682024[28] = dt;
   out_8962950086978682024[29] = 0;
   out_8962950086978682024[30] = 0;
   out_8962950086978682024[31] = 0;
   out_8962950086978682024[32] = 0;
   out_8962950086978682024[33] = 0;
   out_8962950086978682024[34] = 0;
   out_8962950086978682024[35] = 0;
   out_8962950086978682024[36] = 0;
   out_8962950086978682024[37] = 0;
   out_8962950086978682024[38] = 0;
   out_8962950086978682024[39] = 0;
   out_8962950086978682024[40] = 0;
   out_8962950086978682024[41] = 0;
   out_8962950086978682024[42] = 0;
   out_8962950086978682024[43] = 0;
   out_8962950086978682024[44] = 1;
   out_8962950086978682024[45] = 0;
   out_8962950086978682024[46] = 0;
   out_8962950086978682024[47] = 0;
   out_8962950086978682024[48] = 0;
   out_8962950086978682024[49] = 0;
   out_8962950086978682024[50] = dt;
   out_8962950086978682024[51] = 0;
   out_8962950086978682024[52] = 0;
   out_8962950086978682024[53] = 0;
   out_8962950086978682024[54] = 0;
   out_8962950086978682024[55] = 0;
   out_8962950086978682024[56] = 0;
   out_8962950086978682024[57] = 0;
   out_8962950086978682024[58] = 0;
   out_8962950086978682024[59] = 0;
   out_8962950086978682024[60] = 0;
   out_8962950086978682024[61] = 0;
   out_8962950086978682024[62] = 0;
   out_8962950086978682024[63] = 0;
   out_8962950086978682024[64] = 0;
   out_8962950086978682024[65] = 0;
   out_8962950086978682024[66] = 1;
   out_8962950086978682024[67] = dt*((2*state[3]*state[4] + 2*state[5]*state[6])*state[11] + (-2*state[3]*state[5] + 2*state[4]*state[6])*state[10] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[12]);
   out_8962950086978682024[68] = dt*((2*state[3]*state[4] - 2*state[5]*state[6])*state[12] + (-2*state[3]*state[6] - 2*state[4]*state[5])*state[10] + (-pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[11]);
   out_8962950086978682024[69] = 0;
   out_8962950086978682024[70] = 0;
   out_8962950086978682024[71] = 0;
   out_8962950086978682024[72] = dt*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2));
   out_8962950086978682024[73] = dt*(-2*state[3]*state[6] + 2*state[4]*state[5]);
   out_8962950086978682024[74] = dt*(2*state[3]*state[5] + 2*state[4]*state[6]);
   out_8962950086978682024[75] = 0;
   out_8962950086978682024[76] = 0;
   out_8962950086978682024[77] = 0;
   out_8962950086978682024[78] = 0;
   out_8962950086978682024[79] = 0;
   out_8962950086978682024[80] = 0;
   out_8962950086978682024[81] = 0;
   out_8962950086978682024[82] = 0;
   out_8962950086978682024[83] = 0;
   out_8962950086978682024[84] = 0;
   out_8962950086978682024[85] = 0;
   out_8962950086978682024[86] = 0;
   out_8962950086978682024[87] = dt*(-(2*state[3]*state[4] + 2*state[5]*state[6])*state[11] - (-2*state[3]*state[5] + 2*state[4]*state[6])*state[10] - (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[12]);
   out_8962950086978682024[88] = 1;
   out_8962950086978682024[89] = dt*((2*state[3]*state[5] + 2*state[4]*state[6])*state[12] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[11] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[10]);
   out_8962950086978682024[90] = 0;
   out_8962950086978682024[91] = 0;
   out_8962950086978682024[92] = 0;
   out_8962950086978682024[93] = dt*(2*state[3]*state[6] + 2*state[4]*state[5]);
   out_8962950086978682024[94] = dt*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2));
   out_8962950086978682024[95] = dt*(-2*state[3]*state[4] + 2*state[5]*state[6]);
   out_8962950086978682024[96] = 0;
   out_8962950086978682024[97] = 0;
   out_8962950086978682024[98] = 0;
   out_8962950086978682024[99] = 0;
   out_8962950086978682024[100] = 0;
   out_8962950086978682024[101] = 0;
   out_8962950086978682024[102] = 0;
   out_8962950086978682024[103] = 0;
   out_8962950086978682024[104] = 0;
   out_8962950086978682024[105] = 0;
   out_8962950086978682024[106] = 0;
   out_8962950086978682024[107] = 0;
   out_8962950086978682024[108] = dt*((-2*state[3]*state[4] + 2*state[5]*state[6])*state[12] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[10] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[11]);
   out_8962950086978682024[109] = dt*((-2*state[3]*state[5] - 2*state[4]*state[6])*state[12] + (2*state[3]*state[6] - 2*state[4]*state[5])*state[11] + (-pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) + pow(state[6], 2))*state[10]);
   out_8962950086978682024[110] = 1;
   out_8962950086978682024[111] = 0;
   out_8962950086978682024[112] = 0;
   out_8962950086978682024[113] = 0;
   out_8962950086978682024[114] = dt*(-2*state[3]*state[5] + 2*state[4]*state[6]);
   out_8962950086978682024[115] = dt*(2*state[3]*state[4] + 2*state[5]*state[6]);
   out_8962950086978682024[116] = dt*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2));
   out_8962950086978682024[117] = 0;
   out_8962950086978682024[118] = 0;
   out_8962950086978682024[119] = 0;
   out_8962950086978682024[120] = 0;
   out_8962950086978682024[121] = 0;
   out_8962950086978682024[122] = 0;
   out_8962950086978682024[123] = 0;
   out_8962950086978682024[124] = 0;
   out_8962950086978682024[125] = 0;
   out_8962950086978682024[126] = 0;
   out_8962950086978682024[127] = 0;
   out_8962950086978682024[128] = 0;
   out_8962950086978682024[129] = 0;
   out_8962950086978682024[130] = dt*((2*state[3]*state[4] + 2*state[5]*state[6])*state[17] + (-2*state[3]*state[5] + 2*state[4]*state[6])*state[16] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[18]);
   out_8962950086978682024[131] = dt*((2*state[3]*state[4] - 2*state[5]*state[6])*state[18] + (-2*state[3]*state[6] - 2*state[4]*state[5])*state[16] + (-pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[17]);
   out_8962950086978682024[132] = 1;
   out_8962950086978682024[133] = 0;
   out_8962950086978682024[134] = 0;
   out_8962950086978682024[135] = 0;
   out_8962950086978682024[136] = 0;
   out_8962950086978682024[137] = 0;
   out_8962950086978682024[138] = 0;
   out_8962950086978682024[139] = 0;
   out_8962950086978682024[140] = 0;
   out_8962950086978682024[141] = dt*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2));
   out_8962950086978682024[142] = dt*(-2*state[3]*state[6] + 2*state[4]*state[5]);
   out_8962950086978682024[143] = dt*(2*state[3]*state[5] + 2*state[4]*state[6]);
   out_8962950086978682024[144] = 0;
   out_8962950086978682024[145] = 0;
   out_8962950086978682024[146] = 0;
   out_8962950086978682024[147] = 0;
   out_8962950086978682024[148] = 0;
   out_8962950086978682024[149] = 0;
   out_8962950086978682024[150] = dt*(-(2*state[3]*state[4] + 2*state[5]*state[6])*state[17] - (-2*state[3]*state[5] + 2*state[4]*state[6])*state[16] - (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[18]);
   out_8962950086978682024[151] = 0;
   out_8962950086978682024[152] = dt*((2*state[3]*state[5] + 2*state[4]*state[6])*state[18] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[17] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[16]);
   out_8962950086978682024[153] = 0;
   out_8962950086978682024[154] = 1;
   out_8962950086978682024[155] = 0;
   out_8962950086978682024[156] = 0;
   out_8962950086978682024[157] = 0;
   out_8962950086978682024[158] = 0;
   out_8962950086978682024[159] = 0;
   out_8962950086978682024[160] = 0;
   out_8962950086978682024[161] = 0;
   out_8962950086978682024[162] = dt*(2*state[3]*state[6] + 2*state[4]*state[5]);
   out_8962950086978682024[163] = dt*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2));
   out_8962950086978682024[164] = dt*(-2*state[3]*state[4] + 2*state[5]*state[6]);
   out_8962950086978682024[165] = 0;
   out_8962950086978682024[166] = 0;
   out_8962950086978682024[167] = 0;
   out_8962950086978682024[168] = 0;
   out_8962950086978682024[169] = 0;
   out_8962950086978682024[170] = 0;
   out_8962950086978682024[171] = dt*((-2*state[3]*state[4] + 2*state[5]*state[6])*state[18] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[16] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[17]);
   out_8962950086978682024[172] = dt*((-2*state[3]*state[5] - 2*state[4]*state[6])*state[18] + (2*state[3]*state[6] - 2*state[4]*state[5])*state[17] + (-pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) + pow(state[6], 2))*state[16]);
   out_8962950086978682024[173] = 0;
   out_8962950086978682024[174] = 0;
   out_8962950086978682024[175] = 0;
   out_8962950086978682024[176] = 1;
   out_8962950086978682024[177] = 0;
   out_8962950086978682024[178] = 0;
   out_8962950086978682024[179] = 0;
   out_8962950086978682024[180] = 0;
   out_8962950086978682024[181] = 0;
   out_8962950086978682024[182] = 0;
   out_8962950086978682024[183] = dt*(-2*state[3]*state[5] + 2*state[4]*state[6]);
   out_8962950086978682024[184] = dt*(2*state[3]*state[4] + 2*state[5]*state[6]);
   out_8962950086978682024[185] = dt*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2));
   out_8962950086978682024[186] = 0;
   out_8962950086978682024[187] = 0;
   out_8962950086978682024[188] = 0;
   out_8962950086978682024[189] = 0;
   out_8962950086978682024[190] = 0;
   out_8962950086978682024[191] = 0;
   out_8962950086978682024[192] = 0;
   out_8962950086978682024[193] = 0;
   out_8962950086978682024[194] = 0;
   out_8962950086978682024[195] = 0;
   out_8962950086978682024[196] = 0;
   out_8962950086978682024[197] = 0;
   out_8962950086978682024[198] = 1;
   out_8962950086978682024[199] = 0;
   out_8962950086978682024[200] = 0;
   out_8962950086978682024[201] = 0;
   out_8962950086978682024[202] = 0;
   out_8962950086978682024[203] = 0;
   out_8962950086978682024[204] = 0;
   out_8962950086978682024[205] = 0;
   out_8962950086978682024[206] = 0;
   out_8962950086978682024[207] = 0;
   out_8962950086978682024[208] = 0;
   out_8962950086978682024[209] = 0;
   out_8962950086978682024[210] = 0;
   out_8962950086978682024[211] = 0;
   out_8962950086978682024[212] = 0;
   out_8962950086978682024[213] = 0;
   out_8962950086978682024[214] = 0;
   out_8962950086978682024[215] = 0;
   out_8962950086978682024[216] = 0;
   out_8962950086978682024[217] = 0;
   out_8962950086978682024[218] = 0;
   out_8962950086978682024[219] = 0;
   out_8962950086978682024[220] = 1;
   out_8962950086978682024[221] = 0;
   out_8962950086978682024[222] = 0;
   out_8962950086978682024[223] = 0;
   out_8962950086978682024[224] = 0;
   out_8962950086978682024[225] = 0;
   out_8962950086978682024[226] = 0;
   out_8962950086978682024[227] = 0;
   out_8962950086978682024[228] = 0;
   out_8962950086978682024[229] = 0;
   out_8962950086978682024[230] = 0;
   out_8962950086978682024[231] = 0;
   out_8962950086978682024[232] = 0;
   out_8962950086978682024[233] = 0;
   out_8962950086978682024[234] = 0;
   out_8962950086978682024[235] = 0;
   out_8962950086978682024[236] = 0;
   out_8962950086978682024[237] = 0;
   out_8962950086978682024[238] = 0;
   out_8962950086978682024[239] = 0;
   out_8962950086978682024[240] = 0;
   out_8962950086978682024[241] = 0;
   out_8962950086978682024[242] = 1;
   out_8962950086978682024[243] = 0;
   out_8962950086978682024[244] = 0;
   out_8962950086978682024[245] = 0;
   out_8962950086978682024[246] = 0;
   out_8962950086978682024[247] = 0;
   out_8962950086978682024[248] = 0;
   out_8962950086978682024[249] = 0;
   out_8962950086978682024[250] = 0;
   out_8962950086978682024[251] = 0;
   out_8962950086978682024[252] = 0;
   out_8962950086978682024[253] = 0;
   out_8962950086978682024[254] = 0;
   out_8962950086978682024[255] = 0;
   out_8962950086978682024[256] = 0;
   out_8962950086978682024[257] = 0;
   out_8962950086978682024[258] = 0;
   out_8962950086978682024[259] = 0;
   out_8962950086978682024[260] = 0;
   out_8962950086978682024[261] = 0;
   out_8962950086978682024[262] = 0;
   out_8962950086978682024[263] = 0;
   out_8962950086978682024[264] = 1;
   out_8962950086978682024[265] = 0;
   out_8962950086978682024[266] = 0;
   out_8962950086978682024[267] = 0;
   out_8962950086978682024[268] = 0;
   out_8962950086978682024[269] = 0;
   out_8962950086978682024[270] = 0;
   out_8962950086978682024[271] = 0;
   out_8962950086978682024[272] = 0;
   out_8962950086978682024[273] = 0;
   out_8962950086978682024[274] = 0;
   out_8962950086978682024[275] = 0;
   out_8962950086978682024[276] = 0;
   out_8962950086978682024[277] = 0;
   out_8962950086978682024[278] = 0;
   out_8962950086978682024[279] = 0;
   out_8962950086978682024[280] = 0;
   out_8962950086978682024[281] = 0;
   out_8962950086978682024[282] = 0;
   out_8962950086978682024[283] = 0;
   out_8962950086978682024[284] = 0;
   out_8962950086978682024[285] = 0;
   out_8962950086978682024[286] = 1;
   out_8962950086978682024[287] = 0;
   out_8962950086978682024[288] = 0;
   out_8962950086978682024[289] = 0;
   out_8962950086978682024[290] = 0;
   out_8962950086978682024[291] = 0;
   out_8962950086978682024[292] = 0;
   out_8962950086978682024[293] = 0;
   out_8962950086978682024[294] = 0;
   out_8962950086978682024[295] = 0;
   out_8962950086978682024[296] = 0;
   out_8962950086978682024[297] = 0;
   out_8962950086978682024[298] = 0;
   out_8962950086978682024[299] = 0;
   out_8962950086978682024[300] = 0;
   out_8962950086978682024[301] = 0;
   out_8962950086978682024[302] = 0;
   out_8962950086978682024[303] = 0;
   out_8962950086978682024[304] = 0;
   out_8962950086978682024[305] = 0;
   out_8962950086978682024[306] = 0;
   out_8962950086978682024[307] = 0;
   out_8962950086978682024[308] = 1;
   out_8962950086978682024[309] = 0;
   out_8962950086978682024[310] = 0;
   out_8962950086978682024[311] = 0;
   out_8962950086978682024[312] = 0;
   out_8962950086978682024[313] = 0;
   out_8962950086978682024[314] = 0;
   out_8962950086978682024[315] = 0;
   out_8962950086978682024[316] = 0;
   out_8962950086978682024[317] = 0;
   out_8962950086978682024[318] = 0;
   out_8962950086978682024[319] = 0;
   out_8962950086978682024[320] = 0;
   out_8962950086978682024[321] = 0;
   out_8962950086978682024[322] = 0;
   out_8962950086978682024[323] = 0;
   out_8962950086978682024[324] = 0;
   out_8962950086978682024[325] = 0;
   out_8962950086978682024[326] = 0;
   out_8962950086978682024[327] = 0;
   out_8962950086978682024[328] = 0;
   out_8962950086978682024[329] = 0;
   out_8962950086978682024[330] = 1;
   out_8962950086978682024[331] = 0;
   out_8962950086978682024[332] = 0;
   out_8962950086978682024[333] = 0;
   out_8962950086978682024[334] = 0;
   out_8962950086978682024[335] = 0;
   out_8962950086978682024[336] = 0;
   out_8962950086978682024[337] = 0;
   out_8962950086978682024[338] = 0;
   out_8962950086978682024[339] = 0;
   out_8962950086978682024[340] = 0;
   out_8962950086978682024[341] = 0;
   out_8962950086978682024[342] = 0;
   out_8962950086978682024[343] = 0;
   out_8962950086978682024[344] = 0;
   out_8962950086978682024[345] = 0;
   out_8962950086978682024[346] = 0;
   out_8962950086978682024[347] = 0;
   out_8962950086978682024[348] = 0;
   out_8962950086978682024[349] = 0;
   out_8962950086978682024[350] = 0;
   out_8962950086978682024[351] = 0;
   out_8962950086978682024[352] = 1;
   out_8962950086978682024[353] = 0;
   out_8962950086978682024[354] = 0;
   out_8962950086978682024[355] = 0;
   out_8962950086978682024[356] = 0;
   out_8962950086978682024[357] = 0;
   out_8962950086978682024[358] = 0;
   out_8962950086978682024[359] = 0;
   out_8962950086978682024[360] = 0;
   out_8962950086978682024[361] = 0;
   out_8962950086978682024[362] = 0;
   out_8962950086978682024[363] = 0;
   out_8962950086978682024[364] = 0;
   out_8962950086978682024[365] = 0;
   out_8962950086978682024[366] = 0;
   out_8962950086978682024[367] = 0;
   out_8962950086978682024[368] = 0;
   out_8962950086978682024[369] = 0;
   out_8962950086978682024[370] = 0;
   out_8962950086978682024[371] = 0;
   out_8962950086978682024[372] = 0;
   out_8962950086978682024[373] = 0;
   out_8962950086978682024[374] = 1;
   out_8962950086978682024[375] = 0;
   out_8962950086978682024[376] = 0;
   out_8962950086978682024[377] = 0;
   out_8962950086978682024[378] = 0;
   out_8962950086978682024[379] = 0;
   out_8962950086978682024[380] = 0;
   out_8962950086978682024[381] = 0;
   out_8962950086978682024[382] = 0;
   out_8962950086978682024[383] = 0;
   out_8962950086978682024[384] = 0;
   out_8962950086978682024[385] = 0;
   out_8962950086978682024[386] = 0;
   out_8962950086978682024[387] = 0;
   out_8962950086978682024[388] = 0;
   out_8962950086978682024[389] = 0;
   out_8962950086978682024[390] = 0;
   out_8962950086978682024[391] = 0;
   out_8962950086978682024[392] = 0;
   out_8962950086978682024[393] = 0;
   out_8962950086978682024[394] = 0;
   out_8962950086978682024[395] = 0;
   out_8962950086978682024[396] = 1;
   out_8962950086978682024[397] = 0;
   out_8962950086978682024[398] = 0;
   out_8962950086978682024[399] = 0;
   out_8962950086978682024[400] = 0;
   out_8962950086978682024[401] = 0;
   out_8962950086978682024[402] = 0;
   out_8962950086978682024[403] = 0;
   out_8962950086978682024[404] = 0;
   out_8962950086978682024[405] = 0;
   out_8962950086978682024[406] = 0;
   out_8962950086978682024[407] = 0;
   out_8962950086978682024[408] = 0;
   out_8962950086978682024[409] = 0;
   out_8962950086978682024[410] = 0;
   out_8962950086978682024[411] = 0;
   out_8962950086978682024[412] = 0;
   out_8962950086978682024[413] = 0;
   out_8962950086978682024[414] = 0;
   out_8962950086978682024[415] = 0;
   out_8962950086978682024[416] = 0;
   out_8962950086978682024[417] = 0;
   out_8962950086978682024[418] = 1;
   out_8962950086978682024[419] = 0;
   out_8962950086978682024[420] = 0;
   out_8962950086978682024[421] = 0;
   out_8962950086978682024[422] = 0;
   out_8962950086978682024[423] = 0;
   out_8962950086978682024[424] = 0;
   out_8962950086978682024[425] = 0;
   out_8962950086978682024[426] = 0;
   out_8962950086978682024[427] = 0;
   out_8962950086978682024[428] = 0;
   out_8962950086978682024[429] = 0;
   out_8962950086978682024[430] = 0;
   out_8962950086978682024[431] = 0;
   out_8962950086978682024[432] = 0;
   out_8962950086978682024[433] = 0;
   out_8962950086978682024[434] = 0;
   out_8962950086978682024[435] = 0;
   out_8962950086978682024[436] = 0;
   out_8962950086978682024[437] = 0;
   out_8962950086978682024[438] = 0;
   out_8962950086978682024[439] = 0;
   out_8962950086978682024[440] = 1;
}
void h_4(double *state, double *unused, double *out_1777498685180261346) {
   out_1777498685180261346[0] = state[10] + state[13];
   out_1777498685180261346[1] = state[11] + state[14];
   out_1777498685180261346[2] = state[12] + state[15];
}
void H_4(double *state, double *unused, double *out_4137287014202993190) {
   out_4137287014202993190[0] = 0;
   out_4137287014202993190[1] = 0;
   out_4137287014202993190[2] = 0;
   out_4137287014202993190[3] = 0;
   out_4137287014202993190[4] = 0;
   out_4137287014202993190[5] = 0;
   out_4137287014202993190[6] = 0;
   out_4137287014202993190[7] = 0;
   out_4137287014202993190[8] = 0;
   out_4137287014202993190[9] = 0;
   out_4137287014202993190[10] = 1;
   out_4137287014202993190[11] = 0;
   out_4137287014202993190[12] = 0;
   out_4137287014202993190[13] = 1;
   out_4137287014202993190[14] = 0;
   out_4137287014202993190[15] = 0;
   out_4137287014202993190[16] = 0;
   out_4137287014202993190[17] = 0;
   out_4137287014202993190[18] = 0;
   out_4137287014202993190[19] = 0;
   out_4137287014202993190[20] = 0;
   out_4137287014202993190[21] = 0;
   out_4137287014202993190[22] = 0;
   out_4137287014202993190[23] = 0;
   out_4137287014202993190[24] = 0;
   out_4137287014202993190[25] = 0;
   out_4137287014202993190[26] = 0;
   out_4137287014202993190[27] = 0;
   out_4137287014202993190[28] = 0;
   out_4137287014202993190[29] = 0;
   out_4137287014202993190[30] = 0;
   out_4137287014202993190[31] = 0;
   out_4137287014202993190[32] = 0;
   out_4137287014202993190[33] = 1;
   out_4137287014202993190[34] = 0;
   out_4137287014202993190[35] = 0;
   out_4137287014202993190[36] = 1;
   out_4137287014202993190[37] = 0;
   out_4137287014202993190[38] = 0;
   out_4137287014202993190[39] = 0;
   out_4137287014202993190[40] = 0;
   out_4137287014202993190[41] = 0;
   out_4137287014202993190[42] = 0;
   out_4137287014202993190[43] = 0;
   out_4137287014202993190[44] = 0;
   out_4137287014202993190[45] = 0;
   out_4137287014202993190[46] = 0;
   out_4137287014202993190[47] = 0;
   out_4137287014202993190[48] = 0;
   out_4137287014202993190[49] = 0;
   out_4137287014202993190[50] = 0;
   out_4137287014202993190[51] = 0;
   out_4137287014202993190[52] = 0;
   out_4137287014202993190[53] = 0;
   out_4137287014202993190[54] = 0;
   out_4137287014202993190[55] = 0;
   out_4137287014202993190[56] = 1;
   out_4137287014202993190[57] = 0;
   out_4137287014202993190[58] = 0;
   out_4137287014202993190[59] = 1;
   out_4137287014202993190[60] = 0;
   out_4137287014202993190[61] = 0;
   out_4137287014202993190[62] = 0;
   out_4137287014202993190[63] = 0;
   out_4137287014202993190[64] = 0;
   out_4137287014202993190[65] = 0;
}
void h_9(double *state, double *unused, double *out_4762408851873785060) {
   out_4762408851873785060[0] = state[10];
   out_4762408851873785060[1] = state[11];
   out_4762408851873785060[2] = state[12];
}
void H_9(double *state, double *unused, double *out_4378476660832583835) {
   out_4378476660832583835[0] = 0;
   out_4378476660832583835[1] = 0;
   out_4378476660832583835[2] = 0;
   out_4378476660832583835[3] = 0;
   out_4378476660832583835[4] = 0;
   out_4378476660832583835[5] = 0;
   out_4378476660832583835[6] = 0;
   out_4378476660832583835[7] = 0;
   out_4378476660832583835[8] = 0;
   out_4378476660832583835[9] = 0;
   out_4378476660832583835[10] = 1;
   out_4378476660832583835[11] = 0;
   out_4378476660832583835[12] = 0;
   out_4378476660832583835[13] = 0;
   out_4378476660832583835[14] = 0;
   out_4378476660832583835[15] = 0;
   out_4378476660832583835[16] = 0;
   out_4378476660832583835[17] = 0;
   out_4378476660832583835[18] = 0;
   out_4378476660832583835[19] = 0;
   out_4378476660832583835[20] = 0;
   out_4378476660832583835[21] = 0;
   out_4378476660832583835[22] = 0;
   out_4378476660832583835[23] = 0;
   out_4378476660832583835[24] = 0;
   out_4378476660832583835[25] = 0;
   out_4378476660832583835[26] = 0;
   out_4378476660832583835[27] = 0;
   out_4378476660832583835[28] = 0;
   out_4378476660832583835[29] = 0;
   out_4378476660832583835[30] = 0;
   out_4378476660832583835[31] = 0;
   out_4378476660832583835[32] = 0;
   out_4378476660832583835[33] = 1;
   out_4378476660832583835[34] = 0;
   out_4378476660832583835[35] = 0;
   out_4378476660832583835[36] = 0;
   out_4378476660832583835[37] = 0;
   out_4378476660832583835[38] = 0;
   out_4378476660832583835[39] = 0;
   out_4378476660832583835[40] = 0;
   out_4378476660832583835[41] = 0;
   out_4378476660832583835[42] = 0;
   out_4378476660832583835[43] = 0;
   out_4378476660832583835[44] = 0;
   out_4378476660832583835[45] = 0;
   out_4378476660832583835[46] = 0;
   out_4378476660832583835[47] = 0;
   out_4378476660832583835[48] = 0;
   out_4378476660832583835[49] = 0;
   out_4378476660832583835[50] = 0;
   out_4378476660832583835[51] = 0;
   out_4378476660832583835[52] = 0;
   out_4378476660832583835[53] = 0;
   out_4378476660832583835[54] = 0;
   out_4378476660832583835[55] = 0;
   out_4378476660832583835[56] = 1;
   out_4378476660832583835[57] = 0;
   out_4378476660832583835[58] = 0;
   out_4378476660832583835[59] = 0;
   out_4378476660832583835[60] = 0;
   out_4378476660832583835[61] = 0;
   out_4378476660832583835[62] = 0;
   out_4378476660832583835[63] = 0;
   out_4378476660832583835[64] = 0;
   out_4378476660832583835[65] = 0;
}
void h_10(double *state, double *unused, double *out_769477702419128333) {
   out_769477702419128333[0] = 398600500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2] + 398600500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1] + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[0] + state[16] + state[19];
   out_769477702419128333[1] = 398600500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2] + 398600500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0] + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[1] + state[17] + state[20];
   out_769477702419128333[2] = 398600500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1] + 398600500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0] + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[2] + state[18] + state[21];
}
void H_10(double *state, double *unused, double *out_607115477708369913) {
   out_607115477708369913[0] = -1195801500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*pow(state[0], 2) + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2));
   out_607115477708369913[1] = -1195801500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[1], 2) + 398600500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[0]*state[1];
   out_607115477708369913[2] = -1195801500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[2], 2) + 398600500000000.0*(-2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*(2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[0]*state[2];
   out_607115477708369913[3] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[6] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[5];
   out_607115477708369913[4] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[6];
   out_607115477708369913[5] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[4] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[3];
   out_607115477708369913[6] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[6] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[4];
   out_607115477708369913[7] = 0;
   out_607115477708369913[8] = 0;
   out_607115477708369913[9] = 0;
   out_607115477708369913[10] = 0;
   out_607115477708369913[11] = 0;
   out_607115477708369913[12] = 0;
   out_607115477708369913[13] = 0;
   out_607115477708369913[14] = 0;
   out_607115477708369913[15] = 0;
   out_607115477708369913[16] = 1;
   out_607115477708369913[17] = 0;
   out_607115477708369913[18] = 0;
   out_607115477708369913[19] = 1;
   out_607115477708369913[20] = 0;
   out_607115477708369913[21] = 0;
   out_607115477708369913[22] = -1195801500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[0], 2) + 398600500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[0]*state[1];
   out_607115477708369913[23] = -1195801500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*pow(state[1], 2) + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2));
   out_607115477708369913[24] = -1195801500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[2], 2) + 398600500000000.0*(2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*(-2*state[3]*state[6] + 2*state[4]*state[5])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[1]*state[2];
   out_607115477708369913[25] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[6] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[4];
   out_607115477708369913[26] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[5] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[3];
   out_607115477708369913[27] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[6];
   out_607115477708369913[28] = -797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[3] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[6] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[5];
   out_607115477708369913[29] = 0;
   out_607115477708369913[30] = 0;
   out_607115477708369913[31] = 0;
   out_607115477708369913[32] = 0;
   out_607115477708369913[33] = 0;
   out_607115477708369913[34] = 0;
   out_607115477708369913[35] = 0;
   out_607115477708369913[36] = 0;
   out_607115477708369913[37] = 0;
   out_607115477708369913[38] = 0;
   out_607115477708369913[39] = 1;
   out_607115477708369913[40] = 0;
   out_607115477708369913[41] = 0;
   out_607115477708369913[42] = 1;
   out_607115477708369913[43] = 0;
   out_607115477708369913[44] = -1195801500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[0], 2) + 398600500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[0]*state[2];
   out_607115477708369913[45] = -1195801500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*pow(state[1], 2) + 398600500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5) - 1195801500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[1] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[1]*state[2];
   out_607115477708369913[46] = -1195801500000000.0*(-2*state[3]*state[4] + 2*state[5]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[1]*state[2] - 1195801500000000.0*(2*state[3]*state[5] + 2*state[4]*state[6])*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*state[0]*state[2] - 1195801500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -2.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*pow(state[2], 2) + 398600500000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*(pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2));
   out_607115477708369913[47] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[5] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[3];
   out_607115477708369913[48] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[6] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[3] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[4];
   out_607115477708369913[49] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[3] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[6] - 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[5];
   out_607115477708369913[50] = 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[0]*state[4] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[1]*state[5] + 797201000000000.0*pow(pow(state[0], 2) + pow(state[1], 2) + pow(state[2], 2), -1.5)*state[2]*state[6];
   out_607115477708369913[51] = 0;
   out_607115477708369913[52] = 0;
   out_607115477708369913[53] = 0;
   out_607115477708369913[54] = 0;
   out_607115477708369913[55] = 0;
   out_607115477708369913[56] = 0;
   out_607115477708369913[57] = 0;
   out_607115477708369913[58] = 0;
   out_607115477708369913[59] = 0;
   out_607115477708369913[60] = 0;
   out_607115477708369913[61] = 0;
   out_607115477708369913[62] = 1;
   out_607115477708369913[63] = 0;
   out_607115477708369913[64] = 0;
   out_607115477708369913[65] = 1;
}
void h_12(double *state, double *unused, double *out_5594886434556651779) {
   out_5594886434556651779[0] = state[0];
   out_5594886434556651779[1] = state[1];
   out_5594886434556651779[2] = state[2];
}
void H_12(double *state, double *unused, double *out_9156743422234954985) {
   out_9156743422234954985[0] = 1;
   out_9156743422234954985[1] = 0;
   out_9156743422234954985[2] = 0;
   out_9156743422234954985[3] = 0;
   out_9156743422234954985[4] = 0;
   out_9156743422234954985[5] = 0;
   out_9156743422234954985[6] = 0;
   out_9156743422234954985[7] = 0;
   out_9156743422234954985[8] = 0;
   out_9156743422234954985[9] = 0;
   out_9156743422234954985[10] = 0;
   out_9156743422234954985[11] = 0;
   out_9156743422234954985[12] = 0;
   out_9156743422234954985[13] = 0;
   out_9156743422234954985[14] = 0;
   out_9156743422234954985[15] = 0;
   out_9156743422234954985[16] = 0;
   out_9156743422234954985[17] = 0;
   out_9156743422234954985[18] = 0;
   out_9156743422234954985[19] = 0;
   out_9156743422234954985[20] = 0;
   out_9156743422234954985[21] = 0;
   out_9156743422234954985[22] = 0;
   out_9156743422234954985[23] = 1;
   out_9156743422234954985[24] = 0;
   out_9156743422234954985[25] = 0;
   out_9156743422234954985[26] = 0;
   out_9156743422234954985[27] = 0;
   out_9156743422234954985[28] = 0;
   out_9156743422234954985[29] = 0;
   out_9156743422234954985[30] = 0;
   out_9156743422234954985[31] = 0;
   out_9156743422234954985[32] = 0;
   out_9156743422234954985[33] = 0;
   out_9156743422234954985[34] = 0;
   out_9156743422234954985[35] = 0;
   out_9156743422234954985[36] = 0;
   out_9156743422234954985[37] = 0;
   out_9156743422234954985[38] = 0;
   out_9156743422234954985[39] = 0;
   out_9156743422234954985[40] = 0;
   out_9156743422234954985[41] = 0;
   out_9156743422234954985[42] = 0;
   out_9156743422234954985[43] = 0;
   out_9156743422234954985[44] = 0;
   out_9156743422234954985[45] = 0;
   out_9156743422234954985[46] = 1;
   out_9156743422234954985[47] = 0;
   out_9156743422234954985[48] = 0;
   out_9156743422234954985[49] = 0;
   out_9156743422234954985[50] = 0;
   out_9156743422234954985[51] = 0;
   out_9156743422234954985[52] = 0;
   out_9156743422234954985[53] = 0;
   out_9156743422234954985[54] = 0;
   out_9156743422234954985[55] = 0;
   out_9156743422234954985[56] = 0;
   out_9156743422234954985[57] = 0;
   out_9156743422234954985[58] = 0;
   out_9156743422234954985[59] = 0;
   out_9156743422234954985[60] = 0;
   out_9156743422234954985[61] = 0;
   out_9156743422234954985[62] = 0;
   out_9156743422234954985[63] = 0;
   out_9156743422234954985[64] = 0;
   out_9156743422234954985[65] = 0;
}
void h_35(double *state, double *unused, double *out_7828238170709544847) {
   out_7828238170709544847[0] = state[7];
   out_7828238170709544847[1] = state[8];
   out_7828238170709544847[2] = state[9];
}
void H_35(double *state, double *unused, double *out_7503949071575600566) {
   out_7503949071575600566[0] = 0;
   out_7503949071575600566[1] = 0;
   out_7503949071575600566[2] = 0;
   out_7503949071575600566[3] = 0;
   out_7503949071575600566[4] = 0;
   out_7503949071575600566[5] = 0;
   out_7503949071575600566[6] = 0;
   out_7503949071575600566[7] = 1;
   out_7503949071575600566[8] = 0;
   out_7503949071575600566[9] = 0;
   out_7503949071575600566[10] = 0;
   out_7503949071575600566[11] = 0;
   out_7503949071575600566[12] = 0;
   out_7503949071575600566[13] = 0;
   out_7503949071575600566[14] = 0;
   out_7503949071575600566[15] = 0;
   out_7503949071575600566[16] = 0;
   out_7503949071575600566[17] = 0;
   out_7503949071575600566[18] = 0;
   out_7503949071575600566[19] = 0;
   out_7503949071575600566[20] = 0;
   out_7503949071575600566[21] = 0;
   out_7503949071575600566[22] = 0;
   out_7503949071575600566[23] = 0;
   out_7503949071575600566[24] = 0;
   out_7503949071575600566[25] = 0;
   out_7503949071575600566[26] = 0;
   out_7503949071575600566[27] = 0;
   out_7503949071575600566[28] = 0;
   out_7503949071575600566[29] = 0;
   out_7503949071575600566[30] = 1;
   out_7503949071575600566[31] = 0;
   out_7503949071575600566[32] = 0;
   out_7503949071575600566[33] = 0;
   out_7503949071575600566[34] = 0;
   out_7503949071575600566[35] = 0;
   out_7503949071575600566[36] = 0;
   out_7503949071575600566[37] = 0;
   out_7503949071575600566[38] = 0;
   out_7503949071575600566[39] = 0;
   out_7503949071575600566[40] = 0;
   out_7503949071575600566[41] = 0;
   out_7503949071575600566[42] = 0;
   out_7503949071575600566[43] = 0;
   out_7503949071575600566[44] = 0;
   out_7503949071575600566[45] = 0;
   out_7503949071575600566[46] = 0;
   out_7503949071575600566[47] = 0;
   out_7503949071575600566[48] = 0;
   out_7503949071575600566[49] = 0;
   out_7503949071575600566[50] = 0;
   out_7503949071575600566[51] = 0;
   out_7503949071575600566[52] = 0;
   out_7503949071575600566[53] = 1;
   out_7503949071575600566[54] = 0;
   out_7503949071575600566[55] = 0;
   out_7503949071575600566[56] = 0;
   out_7503949071575600566[57] = 0;
   out_7503949071575600566[58] = 0;
   out_7503949071575600566[59] = 0;
   out_7503949071575600566[60] = 0;
   out_7503949071575600566[61] = 0;
   out_7503949071575600566[62] = 0;
   out_7503949071575600566[63] = 0;
   out_7503949071575600566[64] = 0;
   out_7503949071575600566[65] = 0;
}
void h_32(double *state, double *unused, double *out_1198587467706715008) {
   out_1198587467706715008[0] = state[3];
   out_1198587467706715008[1] = state[4];
   out_1198587467706715008[2] = state[5];
   out_1198587467706715008[3] = state[6];
}
void H_32(double *state, double *unused, double *out_5141490629926338492) {
   out_5141490629926338492[0] = 0;
   out_5141490629926338492[1] = 0;
   out_5141490629926338492[2] = 0;
   out_5141490629926338492[3] = 1;
   out_5141490629926338492[4] = 0;
   out_5141490629926338492[5] = 0;
   out_5141490629926338492[6] = 0;
   out_5141490629926338492[7] = 0;
   out_5141490629926338492[8] = 0;
   out_5141490629926338492[9] = 0;
   out_5141490629926338492[10] = 0;
   out_5141490629926338492[11] = 0;
   out_5141490629926338492[12] = 0;
   out_5141490629926338492[13] = 0;
   out_5141490629926338492[14] = 0;
   out_5141490629926338492[15] = 0;
   out_5141490629926338492[16] = 0;
   out_5141490629926338492[17] = 0;
   out_5141490629926338492[18] = 0;
   out_5141490629926338492[19] = 0;
   out_5141490629926338492[20] = 0;
   out_5141490629926338492[21] = 0;
   out_5141490629926338492[22] = 0;
   out_5141490629926338492[23] = 0;
   out_5141490629926338492[24] = 0;
   out_5141490629926338492[25] = 0;
   out_5141490629926338492[26] = 1;
   out_5141490629926338492[27] = 0;
   out_5141490629926338492[28] = 0;
   out_5141490629926338492[29] = 0;
   out_5141490629926338492[30] = 0;
   out_5141490629926338492[31] = 0;
   out_5141490629926338492[32] = 0;
   out_5141490629926338492[33] = 0;
   out_5141490629926338492[34] = 0;
   out_5141490629926338492[35] = 0;
   out_5141490629926338492[36] = 0;
   out_5141490629926338492[37] = 0;
   out_5141490629926338492[38] = 0;
   out_5141490629926338492[39] = 0;
   out_5141490629926338492[40] = 0;
   out_5141490629926338492[41] = 0;
   out_5141490629926338492[42] = 0;
   out_5141490629926338492[43] = 0;
   out_5141490629926338492[44] = 0;
   out_5141490629926338492[45] = 0;
   out_5141490629926338492[46] = 0;
   out_5141490629926338492[47] = 0;
   out_5141490629926338492[48] = 0;
   out_5141490629926338492[49] = 1;
   out_5141490629926338492[50] = 0;
   out_5141490629926338492[51] = 0;
   out_5141490629926338492[52] = 0;
   out_5141490629926338492[53] = 0;
   out_5141490629926338492[54] = 0;
   out_5141490629926338492[55] = 0;
   out_5141490629926338492[56] = 0;
   out_5141490629926338492[57] = 0;
   out_5141490629926338492[58] = 0;
   out_5141490629926338492[59] = 0;
   out_5141490629926338492[60] = 0;
   out_5141490629926338492[61] = 0;
   out_5141490629926338492[62] = 0;
   out_5141490629926338492[63] = 0;
   out_5141490629926338492[64] = 0;
   out_5141490629926338492[65] = 0;
   out_5141490629926338492[66] = 0;
   out_5141490629926338492[67] = 0;
   out_5141490629926338492[68] = 0;
   out_5141490629926338492[69] = 0;
   out_5141490629926338492[70] = 0;
   out_5141490629926338492[71] = 0;
   out_5141490629926338492[72] = 1;
   out_5141490629926338492[73] = 0;
   out_5141490629926338492[74] = 0;
   out_5141490629926338492[75] = 0;
   out_5141490629926338492[76] = 0;
   out_5141490629926338492[77] = 0;
   out_5141490629926338492[78] = 0;
   out_5141490629926338492[79] = 0;
   out_5141490629926338492[80] = 0;
   out_5141490629926338492[81] = 0;
   out_5141490629926338492[82] = 0;
   out_5141490629926338492[83] = 0;
   out_5141490629926338492[84] = 0;
   out_5141490629926338492[85] = 0;
   out_5141490629926338492[86] = 0;
   out_5141490629926338492[87] = 0;
}
void h_13(double *state, double *unused, double *out_4446144489578117053) {
   out_4446144489578117053[0] = (-2*state[3]*state[5] + 2*state[4]*state[6])*state[9] + (2*state[3]*state[6] + 2*state[4]*state[5])*state[8] + (pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2))*state[7];
   out_4446144489578117053[1] = (2*state[3]*state[4] + 2*state[5]*state[6])*state[9] + (-2*state[3]*state[6] + 2*state[4]*state[5])*state[7] + (pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2))*state[8];
   out_4446144489578117053[2] = (-2*state[3]*state[4] + 2*state[5]*state[6])*state[8] + (2*state[3]*state[5] + 2*state[4]*state[6])*state[7] + (pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2))*state[9];
}
void H_13(double *state, double *unused, double *out_8954114104359138418) {
   out_8954114104359138418[0] = 0;
   out_8954114104359138418[1] = 0;
   out_8954114104359138418[2] = 0;
   out_8954114104359138418[3] = 2*state[3]*state[7] - 2*state[5]*state[9] + 2*state[6]*state[8];
   out_8954114104359138418[4] = 2*state[4]*state[7] + 2*state[5]*state[8] + 2*state[6]*state[9];
   out_8954114104359138418[5] = -2*state[3]*state[9] + 2*state[4]*state[8] - 2*state[5]*state[7];
   out_8954114104359138418[6] = 2*state[3]*state[8] + 2*state[4]*state[9] - 2*state[6]*state[7];
   out_8954114104359138418[7] = pow(state[3], 2) + pow(state[4], 2) - pow(state[5], 2) - pow(state[6], 2);
   out_8954114104359138418[8] = 2*state[3]*state[6] + 2*state[4]*state[5];
   out_8954114104359138418[9] = -2*state[3]*state[5] + 2*state[4]*state[6];
   out_8954114104359138418[10] = 0;
   out_8954114104359138418[11] = 0;
   out_8954114104359138418[12] = 0;
   out_8954114104359138418[13] = 0;
   out_8954114104359138418[14] = 0;
   out_8954114104359138418[15] = 0;
   out_8954114104359138418[16] = 0;
   out_8954114104359138418[17] = 0;
   out_8954114104359138418[18] = 0;
   out_8954114104359138418[19] = 0;
   out_8954114104359138418[20] = 0;
   out_8954114104359138418[21] = 0;
   out_8954114104359138418[22] = 0;
   out_8954114104359138418[23] = 0;
   out_8954114104359138418[24] = 0;
   out_8954114104359138418[25] = 2*state[3]*state[8] + 2*state[4]*state[9] - 2*state[6]*state[7];
   out_8954114104359138418[26] = 2*state[3]*state[9] - 2*state[4]*state[8] + 2*state[5]*state[7];
   out_8954114104359138418[27] = 2*state[4]*state[7] + 2*state[5]*state[8] + 2*state[6]*state[9];
   out_8954114104359138418[28] = -2*state[3]*state[7] + 2*state[5]*state[9] - 2*state[6]*state[8];
   out_8954114104359138418[29] = -2*state[3]*state[6] + 2*state[4]*state[5];
   out_8954114104359138418[30] = pow(state[3], 2) - pow(state[4], 2) + pow(state[5], 2) - pow(state[6], 2);
   out_8954114104359138418[31] = 2*state[3]*state[4] + 2*state[5]*state[6];
   out_8954114104359138418[32] = 0;
   out_8954114104359138418[33] = 0;
   out_8954114104359138418[34] = 0;
   out_8954114104359138418[35] = 0;
   out_8954114104359138418[36] = 0;
   out_8954114104359138418[37] = 0;
   out_8954114104359138418[38] = 0;
   out_8954114104359138418[39] = 0;
   out_8954114104359138418[40] = 0;
   out_8954114104359138418[41] = 0;
   out_8954114104359138418[42] = 0;
   out_8954114104359138418[43] = 0;
   out_8954114104359138418[44] = 0;
   out_8954114104359138418[45] = 0;
   out_8954114104359138418[46] = 0;
   out_8954114104359138418[47] = 2*state[3]*state[9] - 2*state[4]*state[8] + 2*state[5]*state[7];
   out_8954114104359138418[48] = -2*state[3]*state[8] - 2*state[4]*state[9] + 2*state[6]*state[7];
   out_8954114104359138418[49] = 2*state[3]*state[7] - 2*state[5]*state[9] + 2*state[6]*state[8];
   out_8954114104359138418[50] = 2*state[4]*state[7] + 2*state[5]*state[8] + 2*state[6]*state[9];
   out_8954114104359138418[51] = 2*state[3]*state[5] + 2*state[4]*state[6];
   out_8954114104359138418[52] = -2*state[3]*state[4] + 2*state[5]*state[6];
   out_8954114104359138418[53] = pow(state[3], 2) - pow(state[4], 2) - pow(state[5], 2) + pow(state[6], 2);
   out_8954114104359138418[54] = 0;
   out_8954114104359138418[55] = 0;
   out_8954114104359138418[56] = 0;
   out_8954114104359138418[57] = 0;
   out_8954114104359138418[58] = 0;
   out_8954114104359138418[59] = 0;
   out_8954114104359138418[60] = 0;
   out_8954114104359138418[61] = 0;
   out_8954114104359138418[62] = 0;
   out_8954114104359138418[63] = 0;
   out_8954114104359138418[64] = 0;
   out_8954114104359138418[65] = 0;
}
void h_14(double *state, double *unused, double *out_4762408851873785060) {
   out_4762408851873785060[0] = state[10];
   out_4762408851873785060[1] = state[11];
   out_4762408851873785060[2] = state[12];
}
void H_14(double *state, double *unused, double *out_4378476660832583835) {
   out_4378476660832583835[0] = 0;
   out_4378476660832583835[1] = 0;
   out_4378476660832583835[2] = 0;
   out_4378476660832583835[3] = 0;
   out_4378476660832583835[4] = 0;
   out_4378476660832583835[5] = 0;
   out_4378476660832583835[6] = 0;
   out_4378476660832583835[7] = 0;
   out_4378476660832583835[8] = 0;
   out_4378476660832583835[9] = 0;
   out_4378476660832583835[10] = 1;
   out_4378476660832583835[11] = 0;
   out_4378476660832583835[12] = 0;
   out_4378476660832583835[13] = 0;
   out_4378476660832583835[14] = 0;
   out_4378476660832583835[15] = 0;
   out_4378476660832583835[16] = 0;
   out_4378476660832583835[17] = 0;
   out_4378476660832583835[18] = 0;
   out_4378476660832583835[19] = 0;
   out_4378476660832583835[20] = 0;
   out_4378476660832583835[21] = 0;
   out_4378476660832583835[22] = 0;
   out_4378476660832583835[23] = 0;
   out_4378476660832583835[24] = 0;
   out_4378476660832583835[25] = 0;
   out_4378476660832583835[26] = 0;
   out_4378476660832583835[27] = 0;
   out_4378476660832583835[28] = 0;
   out_4378476660832583835[29] = 0;
   out_4378476660832583835[30] = 0;
   out_4378476660832583835[31] = 0;
   out_4378476660832583835[32] = 0;
   out_4378476660832583835[33] = 1;
   out_4378476660832583835[34] = 0;
   out_4378476660832583835[35] = 0;
   out_4378476660832583835[36] = 0;
   out_4378476660832583835[37] = 0;
   out_4378476660832583835[38] = 0;
   out_4378476660832583835[39] = 0;
   out_4378476660832583835[40] = 0;
   out_4378476660832583835[41] = 0;
   out_4378476660832583835[42] = 0;
   out_4378476660832583835[43] = 0;
   out_4378476660832583835[44] = 0;
   out_4378476660832583835[45] = 0;
   out_4378476660832583835[46] = 0;
   out_4378476660832583835[47] = 0;
   out_4378476660832583835[48] = 0;
   out_4378476660832583835[49] = 0;
   out_4378476660832583835[50] = 0;
   out_4378476660832583835[51] = 0;
   out_4378476660832583835[52] = 0;
   out_4378476660832583835[53] = 0;
   out_4378476660832583835[54] = 0;
   out_4378476660832583835[55] = 0;
   out_4378476660832583835[56] = 1;
   out_4378476660832583835[57] = 0;
   out_4378476660832583835[58] = 0;
   out_4378476660832583835[59] = 0;
   out_4378476660832583835[60] = 0;
   out_4378476660832583835[61] = 0;
   out_4378476660832583835[62] = 0;
   out_4378476660832583835[63] = 0;
   out_4378476660832583835[64] = 0;
   out_4378476660832583835[65] = 0;
}
void h_33(double *state, double *unused, double *out_8645294225009481236) {
   out_8645294225009481236[0] = state[16];
   out_8645294225009481236[1] = state[17];
   out_8645294225009481236[2] = state[18];
}
void H_33(double *state, double *unused, double *out_7792237997495093446) {
   out_7792237997495093446[0] = 0;
   out_7792237997495093446[1] = 0;
   out_7792237997495093446[2] = 0;
   out_7792237997495093446[3] = 0;
   out_7792237997495093446[4] = 0;
   out_7792237997495093446[5] = 0;
   out_7792237997495093446[6] = 0;
   out_7792237997495093446[7] = 0;
   out_7792237997495093446[8] = 0;
   out_7792237997495093446[9] = 0;
   out_7792237997495093446[10] = 0;
   out_7792237997495093446[11] = 0;
   out_7792237997495093446[12] = 0;
   out_7792237997495093446[13] = 0;
   out_7792237997495093446[14] = 0;
   out_7792237997495093446[15] = 0;
   out_7792237997495093446[16] = 1;
   out_7792237997495093446[17] = 0;
   out_7792237997495093446[18] = 0;
   out_7792237997495093446[19] = 0;
   out_7792237997495093446[20] = 0;
   out_7792237997495093446[21] = 0;
   out_7792237997495093446[22] = 0;
   out_7792237997495093446[23] = 0;
   out_7792237997495093446[24] = 0;
   out_7792237997495093446[25] = 0;
   out_7792237997495093446[26] = 0;
   out_7792237997495093446[27] = 0;
   out_7792237997495093446[28] = 0;
   out_7792237997495093446[29] = 0;
   out_7792237997495093446[30] = 0;
   out_7792237997495093446[31] = 0;
   out_7792237997495093446[32] = 0;
   out_7792237997495093446[33] = 0;
   out_7792237997495093446[34] = 0;
   out_7792237997495093446[35] = 0;
   out_7792237997495093446[36] = 0;
   out_7792237997495093446[37] = 0;
   out_7792237997495093446[38] = 0;
   out_7792237997495093446[39] = 1;
   out_7792237997495093446[40] = 0;
   out_7792237997495093446[41] = 0;
   out_7792237997495093446[42] = 0;
   out_7792237997495093446[43] = 0;
   out_7792237997495093446[44] = 0;
   out_7792237997495093446[45] = 0;
   out_7792237997495093446[46] = 0;
   out_7792237997495093446[47] = 0;
   out_7792237997495093446[48] = 0;
   out_7792237997495093446[49] = 0;
   out_7792237997495093446[50] = 0;
   out_7792237997495093446[51] = 0;
   out_7792237997495093446[52] = 0;
   out_7792237997495093446[53] = 0;
   out_7792237997495093446[54] = 0;
   out_7792237997495093446[55] = 0;
   out_7792237997495093446[56] = 0;
   out_7792237997495093446[57] = 0;
   out_7792237997495093446[58] = 0;
   out_7792237997495093446[59] = 0;
   out_7792237997495093446[60] = 0;
   out_7792237997495093446[61] = 0;
   out_7792237997495093446[62] = 1;
   out_7792237997495093446[63] = 0;
   out_7792237997495093446[64] = 0;
   out_7792237997495093446[65] = 0;
}
#include <eigen3/Eigen/Dense>
#include <iostream>

typedef Eigen::Matrix<double, DIM, DIM, Eigen::RowMajor> DDM;
typedef Eigen::Matrix<double, EDIM, EDIM, Eigen::RowMajor> EEM;
typedef Eigen::Matrix<double, DIM, EDIM, Eigen::RowMajor> DEM;

void predict(double *in_x, double *in_P, double *in_Q, double dt) {
  typedef Eigen::Matrix<double, MEDIM, MEDIM, Eigen::RowMajor> RRM;

  double nx[DIM] = {0};
  double in_F[EDIM*EDIM] = {0};

  // functions from sympy
  f_fun(in_x, dt, nx);
  F_fun(in_x, dt, in_F);


  EEM F(in_F);
  EEM P(in_P);
  EEM Q(in_Q);

  RRM F_main = F.topLeftCorner(MEDIM, MEDIM);
  P.topLeftCorner(MEDIM, MEDIM) = (F_main * P.topLeftCorner(MEDIM, MEDIM)) * F_main.transpose();
  P.topRightCorner(MEDIM, EDIM - MEDIM) = F_main * P.topRightCorner(MEDIM, EDIM - MEDIM);
  P.bottomLeftCorner(EDIM - MEDIM, MEDIM) = P.bottomLeftCorner(EDIM - MEDIM, MEDIM) * F_main.transpose();

  P = P + dt*Q;

  // copy out state
  memcpy(in_x, nx, DIM * sizeof(double));
  memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double));
}

// note: extra_args dim only correct when null space projecting
// otherwise 1
template <int ZDIM, int EADIM, bool MAHA_TEST>
void update(double *in_x, double *in_P, Hfun h_fun, Hfun H_fun, Hfun Hea_fun, double *in_z, double *in_R, double *in_ea, double MAHA_THRESHOLD) {
  typedef Eigen::Matrix<double, ZDIM, ZDIM, Eigen::RowMajor> ZZM;
  typedef Eigen::Matrix<double, ZDIM, DIM, Eigen::RowMajor> ZDM;
  typedef Eigen::Matrix<double, Eigen::Dynamic, EDIM, Eigen::RowMajor> XEM;
  //typedef Eigen::Matrix<double, EDIM, ZDIM, Eigen::RowMajor> EZM;
  typedef Eigen::Matrix<double, Eigen::Dynamic, 1> X1M;
  typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> XXM;

  double in_hx[ZDIM] = {0};
  double in_H[ZDIM * DIM] = {0};
  double in_H_mod[EDIM * DIM] = {0};
  double delta_x[EDIM] = {0};
  double x_new[DIM] = {0};


  // state x, P
  Eigen::Matrix<double, ZDIM, 1> z(in_z);
  EEM P(in_P);
  ZZM pre_R(in_R);

  // functions from sympy
  h_fun(in_x, in_ea, in_hx);
  H_fun(in_x, in_ea, in_H);
  ZDM pre_H(in_H);

  // get y (y = z - hx)
  Eigen::Matrix<double, ZDIM, 1> pre_y(in_hx); pre_y = z - pre_y;
  X1M y; XXM H; XXM R;
  if (Hea_fun){
    typedef Eigen::Matrix<double, ZDIM, EADIM, Eigen::RowMajor> ZAM;
    double in_Hea[ZDIM * EADIM] = {0};
    Hea_fun(in_x, in_ea, in_Hea);
    ZAM Hea(in_Hea);
    XXM A = Hea.transpose().fullPivLu().kernel();


    y = A.transpose() * pre_y;
    H = A.transpose() * pre_H;
    R = A.transpose() * pre_R * A;
  } else {
    y = pre_y;
    H = pre_H;
    R = pre_R;
  }
  // get modified H
  H_mod_fun(in_x, in_H_mod);
  DEM H_mod(in_H_mod);
  XEM H_err = H * H_mod;

  // Do mahalobis distance test
  if (MAHA_TEST){
    XXM a = (H_err * P * H_err.transpose() + R).inverse();
    double maha_dist = y.transpose() * a * y;
    if (maha_dist > MAHA_THRESHOLD){
      R = 1.0e16 * R;
    }
  }

  // Outlier resilient weighting
  double weight = 1;//(1.5)/(1 + y.squaredNorm()/R.sum());

  // kalman gains and I_KH
  XXM S = ((H_err * P) * H_err.transpose()) + R/weight;
  XEM KT = S.fullPivLu().solve(H_err * P.transpose());
  //EZM K = KT.transpose(); TODO: WHY DOES THIS NOT COMPILE?
  //EZM K = S.fullPivLu().solve(H_err * P.transpose()).transpose();
  //std::cout << "Here is the matrix rot:\n" << K << std::endl;
  EEM I_KH = Eigen::Matrix<double, EDIM, EDIM>::Identity() - (KT.transpose() * H_err);

  // update state by injecting dx
  Eigen::Matrix<double, EDIM, 1> dx(delta_x);
  dx  = (KT.transpose() * y);
  memcpy(delta_x, dx.data(), EDIM * sizeof(double));
  err_fun(in_x, delta_x, x_new);
  Eigen::Matrix<double, DIM, 1> x(x_new);

  // update cov
  P = ((I_KH * P) * I_KH.transpose()) + ((KT.transpose() * R) * KT);

  // copy out state
  memcpy(in_x, x.data(), DIM * sizeof(double));
  memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double));
  memcpy(in_z, y.data(), y.rows() * sizeof(double));
}




}
extern "C" {

void live_update_4(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_4, H_4, NULL, in_z, in_R, in_ea, MAHA_THRESH_4);
}
void live_update_9(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_9, H_9, NULL, in_z, in_R, in_ea, MAHA_THRESH_9);
}
void live_update_10(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_10, H_10, NULL, in_z, in_R, in_ea, MAHA_THRESH_10);
}
void live_update_12(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_12, H_12, NULL, in_z, in_R, in_ea, MAHA_THRESH_12);
}
void live_update_35(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_35, H_35, NULL, in_z, in_R, in_ea, MAHA_THRESH_35);
}
void live_update_32(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<4, 3, 0>(in_x, in_P, h_32, H_32, NULL, in_z, in_R, in_ea, MAHA_THRESH_32);
}
void live_update_13(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_13, H_13, NULL, in_z, in_R, in_ea, MAHA_THRESH_13);
}
void live_update_14(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_14, H_14, NULL, in_z, in_R, in_ea, MAHA_THRESH_14);
}
void live_update_33(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {
  update<3, 3, 0>(in_x, in_P, h_33, H_33, NULL, in_z, in_R, in_ea, MAHA_THRESH_33);
}
void live_H(double *in_vec, double *out_3062539955778785123) {
  H(in_vec, out_3062539955778785123);
}
void live_err_fun(double *nom_x, double *delta_x, double *out_997632986539046101) {
  err_fun(nom_x, delta_x, out_997632986539046101);
}
void live_inv_err_fun(double *nom_x, double *true_x, double *out_3959944895181216754) {
  inv_err_fun(nom_x, true_x, out_3959944895181216754);
}
void live_H_mod_fun(double *state, double *out_8702234888023658226) {
  H_mod_fun(state, out_8702234888023658226);
}
void live_f_fun(double *state, double dt, double *out_7459231211064544538) {
  f_fun(state,  dt, out_7459231211064544538);
}
void live_F_fun(double *state, double dt, double *out_8962950086978682024) {
  F_fun(state,  dt, out_8962950086978682024);
}
void live_h_4(double *state, double *unused, double *out_1777498685180261346) {
  h_4(state, unused, out_1777498685180261346);
}
void live_H_4(double *state, double *unused, double *out_4137287014202993190) {
  H_4(state, unused, out_4137287014202993190);
}
void live_h_9(double *state, double *unused, double *out_4762408851873785060) {
  h_9(state, unused, out_4762408851873785060);
}
void live_H_9(double *state, double *unused, double *out_4378476660832583835) {
  H_9(state, unused, out_4378476660832583835);
}
void live_h_10(double *state, double *unused, double *out_769477702419128333) {
  h_10(state, unused, out_769477702419128333);
}
void live_H_10(double *state, double *unused, double *out_607115477708369913) {
  H_10(state, unused, out_607115477708369913);
}
void live_h_12(double *state, double *unused, double *out_5594886434556651779) {
  h_12(state, unused, out_5594886434556651779);
}
void live_H_12(double *state, double *unused, double *out_9156743422234954985) {
  H_12(state, unused, out_9156743422234954985);
}
void live_h_35(double *state, double *unused, double *out_7828238170709544847) {
  h_35(state, unused, out_7828238170709544847);
}
void live_H_35(double *state, double *unused, double *out_7503949071575600566) {
  H_35(state, unused, out_7503949071575600566);
}
void live_h_32(double *state, double *unused, double *out_1198587467706715008) {
  h_32(state, unused, out_1198587467706715008);
}
void live_H_32(double *state, double *unused, double *out_5141490629926338492) {
  H_32(state, unused, out_5141490629926338492);
}
void live_h_13(double *state, double *unused, double *out_4446144489578117053) {
  h_13(state, unused, out_4446144489578117053);
}
void live_H_13(double *state, double *unused, double *out_8954114104359138418) {
  H_13(state, unused, out_8954114104359138418);
}
void live_h_14(double *state, double *unused, double *out_4762408851873785060) {
  h_14(state, unused, out_4762408851873785060);
}
void live_H_14(double *state, double *unused, double *out_4378476660832583835) {
  H_14(state, unused, out_4378476660832583835);
}
void live_h_33(double *state, double *unused, double *out_8645294225009481236) {
  h_33(state, unused, out_8645294225009481236);
}
void live_H_33(double *state, double *unused, double *out_7792237997495093446) {
  H_33(state, unused, out_7792237997495093446);
}
void live_predict(double *in_x, double *in_P, double *in_Q, double dt) {
  predict(in_x, in_P, in_Q, dt);
}
}

const EKF live = {
  .name = "live",
  .kinds = { 4, 9, 10, 12, 35, 32, 13, 14, 33 },
  .feature_kinds = {  },
  .f_fun = live_f_fun,
  .F_fun = live_F_fun,
  .err_fun = live_err_fun,
  .inv_err_fun = live_inv_err_fun,
  .H_mod_fun = live_H_mod_fun,
  .predict = live_predict,
  .hs = {
    { 4, live_h_4 },
    { 9, live_h_9 },
    { 10, live_h_10 },
    { 12, live_h_12 },
    { 35, live_h_35 },
    { 32, live_h_32 },
    { 13, live_h_13 },
    { 14, live_h_14 },
    { 33, live_h_33 },
  },
  .Hs = {
    { 4, live_H_4 },
    { 9, live_H_9 },
    { 10, live_H_10 },
    { 12, live_H_12 },
    { 35, live_H_35 },
    { 32, live_H_32 },
    { 13, live_H_13 },
    { 14, live_H_14 },
    { 33, live_H_33 },
  },
  .updates = {
    { 4, live_update_4 },
    { 9, live_update_9 },
    { 10, live_update_10 },
    { 12, live_update_12 },
    { 35, live_update_35 },
    { 32, live_update_32 },
    { 13, live_update_13 },
    { 14, live_update_14 },
    { 33, live_update_33 },
  },
  .Hes = {
  },
  .sets = {
  },
  .extra_routines = {
    { "H", live_H },
  },
};

ekf_lib_init(live)
